# Replication file for 
# "Activism and the Electoral Participation of Women"
# British Journal of Political Science
# Mona Morgan Collins and Valeria Rueda

rm(list=ls())

# Packs needed
library(tidyverse)
library(fwildclusterboot)
library(sp)
library(sf)
library(cobalt)
library(readxl)
library(stringr)
library(lwgeom)
library(ggplot2)
library(lfe)
library(stargazer)
library(ggpubr)
library(cowplot)
library(gridExtra)
library(Synth)
library(xtable)
library(PupillometryR)

## colors
library(scales)
library(RColorBrewer)
library(ggsci)
library(wesanderson)
library(ggthemes)
library(lfe)
library(ghibli)
sf::sf_use_s2(FALSE) ##  code does not use s2. 

# Regression functions
source("scripts/zfunct_regs_header.R")
# Import data

print(getwd())
#setwd("replication") #Set wd to replication folder

Re <- readRDS("data/regdata_all.RDS")
Ind <- readRDS("data/inddata_all.RDS")

# Define controls
mincont <- c( "log.min.dist.city10k",  
              "log.pop" , "log.dist.roads", 
              "hc1",
              "av_age",  "sexr", "single_"
)
demcont<- c("sc1" , "tfr" , "illeg_rate", 
            "f_smam" ,
            "hc2" ,
            "hc3" ,"hc4" ,"hc5", 
            "fmar_pr", "m_cel_4",
            "f_cel_4" ,
            "ecmr" ,"fwid_pr")

controls <- c(mincont, demcont)
a4ratio <- 210/297

Re$klust <- sapply(strsplit(Re$parl_div, " or "), `[`, 1)
Re$klust <- ifelse(is.na(Re$klust), paste0(Re$county, "-Resid"), Re$klust)

# Paper
## Paper tables
### Table 1
source("scripts/pap_tab_01a.R") # Summary Stats, panel "Individual-Level Data", parts 1-2 
source("scripts/pap_tab_01b.R") # Summary Stats, panel "Division-Level Data", parts 1-2 
### Table 2
source("scripts/pap_tab_02.R") # Individual-Level Analysis: Effects of the March on the P(Female Elector)
### Table 3
source("scripts/pap_tab_03.R") # Division-Level Analysis: Effects of the March on Share Local Electors
### Table 4
source("scripts/pap_tab_04.R") # Division-Level Analysis: Effects of the March on Parliamentary Electors


## Paper figures
### Figure 3
source("scripts/pap_fig_03.R") # Division-Level Analysis: Different Treatment Definitions

# Appendix

## Appendix tables

### Table B1
source("scripts/app_tab_b01.R") # Summary stats by county

### Table C1
source("scripts/app_tab_c01a.R") # Summary Stats, panel "Individual-Level Data", parts 1-2 
source("scripts/app_tab_c01b.R") # Summary Stats, panel "Division-Level Data" , parts 1-3 

### Table D1
source("scripts/app_tab_d01.R") # Baseline Regression, all controls
### Table D3
source("scripts/app_tab_d03.R") # Effect of the march on pro and anti-suffrage

### Table E1
source("scripts/app_tab_e01.R") # Heterogeneity: Urbanization
### Table E2
source("scripts/app_tab_e02.R") # Placebo treat: Main (mostly Roman) roads
### Table E3
source("scripts/app_tab_e03.R") # Restricted control group along main (mostly Roman) roads

### Table F1
source("scripts/app_tab_f01.R") # Compare Treatment to Anti Suffragist
### Table F2
source("scripts/app_tab_f02.R") # Compare Treatment to Strike
### Table F3
source("scripts/app_tab_f03.R") # Compare Treatment to Strike

### Table G1
source("scripts/app_tab_g01.R") # Interact with celibacy
### Table G2
source("scripts/app_tab_g02.R") # Interact with celibacy and high class
### Table G3
source("scripts/app_tab_g03.R") # Interact with single hh
### Table G4
source("scripts/app_tab_g04.R") # Interact with single hh and high class
### Table G5
source("scripts/app_tab_g05.R") # Fixed effects
### Table G6
source("scripts/app_tab_g06.R") # Drop counties
### Table G7
source("scripts/app_tab_g07.R") # WC Bootstrap
### Table G8
source("scripts/app_tab_g08.R") # Treat at cluster


## Appendix figures
### Figure D02
source("scripts/app_fig_d02.R") # Effect of the march on meetings
### Figure E01
source("scripts/app_fig_e01.R") # Basic Trends
### Figure E02
source("scripts/app_fig_e02.R") # Pre Trends
### Figure F01
source("scripts/app_fig_f01.R") # Newspaper mentions of elections
### Figure F04
source("scripts/app_fig_f04.R") # Newspaper mentions of March, nationwide
### Table G1
source("scripts/app_fig_g01.R") # Vary cluster size

